package com.cgbl.cg.ui.login

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.SpanUtils
import com.blankj.utilcode.util.StringUtils
import com.cgbl.cg.BR
import com.cgbl.cg.R
import com.cgbl.cg.databinding.AppActivityBindPhoneCodeBinding
import com.cgbl.cg.vm.login.BindPhoneViewModel
import com.robot.base.base.activity.GLBaseActivity
import com.robot.base.configs.AppConstants
import com.robot.base.util.ToastUtils

@Route(path = AppConstants.Router.Login.A_LOGIN_BIND_PHONE)
class BindPhoneActivity : GLBaseActivity<AppActivityBindPhoneCodeBinding, BindPhoneViewModel>() {

    var name = ""
    var openId = ""
    var imageUrl = ""
    var type = ""
    override fun initContentView(savedInstanceState: Bundle?): Int =
        R.layout.app_activity_bind_phone_code

    override fun initVariableId(): Int = BR.viewModel

    override fun initComponents() {
        addSingleTitleBar("")
        setViewData()
    }

    override fun initData() {
        super.initData()
        viewModel.type = type
        viewModel.openId = openId
        viewModel.name = name
        viewModel.imgUrl = imageUrl
    }
    override fun initParam() {
        super.initParam()
        type = intent.getStringExtra("type") ?: ""
        openId = intent.getStringExtra("openId") ?: ""
        imageUrl = intent.getStringExtra("imageUrl") ?: ""
        name = intent.getStringExtra("name") ?: ""
    }

    private fun setViewData() {
//        binding.tvPrompt.text = StringUtils.getString(R.string.app_en_tips_7)
        SpanUtils.with(binding.tvPrompt)
            .append(StringUtils.getString(R.string.app_en_tips_5))
            .append(StringUtils.getString(R.string.app_en_tips_6))
//            .setForegroundColor(Color.RED)
            .setClickSpan(resources.getColor(R.color.app_286FFF), false) {
                ToastUtils.showShort("点击了用户协议")
            }
            .append(StringUtils.getString(R.string.app_en_tips_8))
            .setForegroundColor(resources.getColor(R.color.app_286FFF))
//            .setQuoteColor(Color.RED)
            .append(StringUtils.getString(R.string.app_en_tips_9))
            .setClickSpan(resources.getColor(R.color.app_286FFF), false) {
                ToastUtils.showShort("点击了隐私协议")
            }
            .create()
    }
}